package com.example.cuibo.elementslearning.dummy;

import android.support.annotation.NonNull;

import org.w3c.dom.ProcessingInstruction;

/**
 * Created by cuibo on 2017/11/1.
 */

public class Person implements Comparable<Person>{
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(@NonNull Person person) {
        int num = this.age - person.age;
        return num == 0 ? this.name.compareTo(person.name) : num;
    }
}

